package cn.crawler.app.crown.commons.websocket.main.result;

import cn.crawler.framework.util.Result;
import lombok.Data;

/**
 * 聊天接口响应结果
 */
@Data
public class NettyResult extends Result {

    private String action;

    private String type;

    private String content;


    public NettyResult(String action, String type, String content) {
        this.action = action;
        this.type = type;
        this.content = content;
    }

    public static NettyResult sysSend(MessageTypeEnum type, ActionEnum action, String content){
        return new NettyResult(action.NAME,type.NAME,content);
    }

    public static NettyResult actionSend(Object user, MessageTypeEnum type, ActionEnum action, String content){
        return new NettyResult(action.NAME,type.NAME,content);
    }

    public enum MessageTypeEnum {
        SYSTEM("sys"),
        SELF("self"),
        USER("user"),
        ATTENDANT("attendant"),
        ACTION("action");
        public final String NAME;

        MessageTypeEnum(String name) {
            NAME = name;
        }
    }

    public enum ActionEnum {
        LEAVE("leave"),
        JOIN("join"),
        READ("read"),
        SEND("send"),
        SEND_GIFT("send_gift"),
        REMAND("remand"),
        DISABLE("disable"),
        ENABLE("enable"),
        SET_MANAGE("setManage"),
        CANCEL_MANAGE("cancelManage"),
        LOGIN_SUCCESS("login_success"),
        LOGIN_ERROR("login_error"),
        SUCCESS("success"),
        ERROR("error")
        ;
        public final String NAME;

        ActionEnum(String name) {
            NAME = name;
        }
    }

}
